/***********************************************************************
 * POJO Class :  SysMenuResource.java
 * Author:  Bill Vison
 * Purpose: Defines the Class SysMenuResource
 ***********************************************************************/

package edu.gtcfla.km.model;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.PrimaryKeyJoinColumn;

import edu.gtcfla.km.FileFormat;
import edu.gtcfla.km.Knowledge;
import edu.gtcfla.km.UploadFile;

@javax.persistence.Entity
@javax.persistence.Table(name = "FILE_UPLOADED")
@PrimaryKeyJoinColumn(name="DOC_ID")
public class UploadFileD extends DocD implements UploadFile{


	private static final long serialVersionUID = -3883186021751223092L;

	@Column(name ="FILE_NAME")		
	private String fileName;
	
	@Override
	public String getFileName() {
		// TODO Auto-generated method stub
		return fileName;
	}

	@Override
	public void setFileName(String fileName) {
		// TODO Auto-generated method stub
		this.fileName = fileName;
	}

	@Column(name ="ext")		
	private String ext;	
	
	@Override
	public String getExt() {
		// TODO Auto-generated method stub
		return ext;
	}

	@Override
	public void setExt(String ext) {
		// TODO Auto-generated method stub
		this.ext = ext;
	}

	@Column(name ="CONTENT_TYPE")		
	private String contentType;		
	
	@Override
	public String getContentType() {
		// TODO Auto-generated method stub
		return contentType;
	}

	@Override
	public void setContentType(String contentType) {
		// TODO Auto-generated method stub
		this.contentType = contentType;
	}

	
	@javax.persistence.ManyToOne(
			cascade = { javax.persistence.CascadeType.MERGE}
			,fetch = javax.persistence.FetchType.LAZY )
	@JoinTable(
			name="ATTACHMENT",
			joinColumns = @JoinColumn( name="attachment_id"),
			inverseJoinColumns = @JoinColumn( name="doc_id")
		)		
	private KnowledgeD knowledgeD;

	public KnowledgeD getKnowledgeD() {
		return knowledgeD;
	}

	public void setKnowledgeD(KnowledgeD knowledgeD) {
		this.knowledgeD = knowledgeD;
	}

	@Override
	public Knowledge getColligation() {
		// TODO Auto-generated method stub
		Knowledge know = this.getKnowledgeD();
		
		return know;
	}

	@Override
	public void setColligation(Knowledge knowledge) {
		// TODO Auto-generated method stub
		this.setKnowledgeD( (KnowledgeD) knowledge );
	}

	@ManyToMany( cascade = {javax.persistence.CascadeType.ALL})
	@JoinTable(
		name="FILE_UPLOADED_FORMAT",
		joinColumns = @JoinColumn( name="doc_id"),
		inverseJoinColumns = @JoinColumn( name="format_id")
	)		
	private Set<FileFormatD> bindingFileFormats = new LinkedHashSet<FileFormatD>();

	public Set<FileFormatD> getBindingFileFormats() {
		return bindingFileFormats;
	}

	public void setBindingFileFormats(Set<FileFormatD> bindingFileFormats) {
		this.bindingFileFormats = bindingFileFormats;
	}
	
	public void addFileFormat(FileFormat ff ) {
		this.bindingFileFormats.add( (FileFormatD) ff );
	}





}